package top.limitblog.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.limitblog.dao.UserDao;
import top.limitblog.pojo.UsersEntity;
import top.limitblog.service.LoginService;

import java.util.List;

/**
 * Created by liuyu on 15/10/2016.
 */
@Service("loginService")
public class LoginServiceImpl implements LoginService {

    @Autowired
    private UserDao userDao;

    public UsersEntity get(String id) {
        return userDao.get(id);
    }

    public List<UsersEntity> findAll() {
        return userDao.findAll();
    }

    public UsersEntity find(UsersEntity user) {
        return userDao.get("from UsersEntity u where u.name=? and u.password=?", new Object[] {user.getName(), user.getPassword()});
    }

    public String save(UsersEntity entity) {
        return userDao.save(entity);
    }

    public void saveOrUpdate(UsersEntity entity) {
        userDao.saveOrUpdate(entity);
    }

    public void delete(String id) {
        userDao.delete(id);
    }

    public void flush() {
        userDao.flush();
    }
}
